<template>
  <div style="padding: 10px">
    <!--    功能区域-->
    <div style="margin: 10px 0">

      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="今日已完成订单" name="first">
          <!--    搜索区域-->
          <div style="margin: 10px 0">

            <el-input placeholder="输入订单号查询" style="width: 20%" v-model="search" clearable></el-input>
            <el-button type="primary" style="margin-left: 5px" @click="load">搜索</el-button>
            <span style="margin-left:20px;margin-right: 20px">选择座位号</span>
            <el-select v-model="seatNumber"  clearable placeholder="请选择"  @change="choiceSeatNumber">
              <el-option

                  v-for="item in seatNumberLIst"
                  :key="item"
                  :label="item"
                  :value="item"
              >
              </el-option>
            </el-select>
            <span style="margin-left: 20PX;">订单总金额 :</span><span style="border: black"> {{allPrice}}</span>
          </div>

          <el-table :data="tableData" stripe style="width: 100%">

            <el-table-column prop="orderNo" label="订单号"></el-table-column>
            <el-table-column prop="goodsname" label="菜品名"></el-table-column>
            <el-table-column prop="price" label="价格"></el-table-column>
            <el-table-column prop="seatNumber" label="座位号"></el-table-column>
            <el-table-column prop="creatTime" label="消费时间"></el-table-column>
            <el-table-column prop="payState" label="支付状态"></el-table-column>
            <el-table-column prop="goodsState" label="菜品状态状态"></el-table-column>



          </el-table>
          <div style="margin: 10px 0">
            <div class="block">

              <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[5, 10, 20]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total"
              >
              </el-pagination>



            </div>
          </div>

        </el-tab-pane>
<!--        <el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>-->
<!--        <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>-->
<!--        <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane>-->
      </el-tabs>
    </div>



  </div>
</template>

<script>


import request from "../../utils/request";

export default {
  name: 'TodayOrder',

  components: {},
  data() {
    return {
      seatNumber:{},
      form: {},
      dialogVisible: false,
      search: '',
      currentPage: 1,
      pageSize:10,
      total: 0,
      seatNumberLIst:[],
      tableData: [],
      activeName:"first"
    }
  },
  created(){
    this.load()
    request.get("/order/loadOrder/history_seat_today").then(res=>{
      res.data.forEach(v=>{
        this.seatNumberLIst.push(v)
      })
    })
    // this.$nextTick(() => {
    //   setInterval(this.load, 5000);
    // });

  },
  computed:{


    allPrice(){
      let sum =0;
      this.tableData.forEach(value => {
       sum += parseInt(value.price)

      })
      return sum;

    }
  },
  methods: {
    choiceSeatNumber(){
      request.get("/order/loadOrder/history_today",{
        params:{
          pageNum:this.currentPage,
          pageSize:this.pageSize,
          seatNumber:this.seatNumber,
          search:this.search}
      }).then(res =>{


        this.tableData = res.data.records
        this.total = res.data.total

      })
    },
    load(){
      // if(this.search!=null)
      request.get("/order/loadOrder/history_today",{
        params:{
          pageNum:this.currentPage,
          pageSize:this.pageSize,
          search:this.search}
      }).then(res =>{


        this.tableData = res.data.records
        this.total = res.data.total

      })
    },


    handleSizeChange( pageSize) { //改变页面显示信息个数
      this.pageSize = pageSize
      this.load()

    }, handleCurrentChange(pageNum) { //改变当前页
      this.currentPage = pageNum
      this.load()
    },


  }
}
</script>
